package edu.sjtu.grid.workflow.facts;

import org.dom4j.Element;

public abstract class Cost {

	public static Cost ParseCost(Element ePC)
	{
		if("fixed".equals(ePC.attributeValue("pay")))
			return new FixedCost(Double.parseDouble(ePC.attributeValue("cost")));
		else
			return new FloatingCost(
				Integer.parseInt(ePC.attributeValue("cycle")),
				Double.parseDouble(ePC.attributeValue("cost1")),
				Integer.parseInt(ePC.attributeValue("time1")),
				Double.parseDouble(ePC.attributeValue("cost2")),
				Integer.parseInt(ePC.attributeValue("time2"))
			);
	}
	
	abstract public boolean isFixed();
	
	abstract public String getPayString();
	
	abstract public String getCostString();
	
	abstract public double getCheapestCost();
	
	abstract public Double getCheapestCost(double from, double to, double duration);
	
	abstract public double getAvgCost();
	
	abstract public double getInitialCost();
	
	abstract public double getNextCheapestTime(double time);
	
	abstract public double getRealCost(double fromTime, double toTime);
}
